/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.org.espmessenger.cliente.telas;

import br.org.espmessenger.modelo.Status;
import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;

/**
 *
 * @author berardo
 */
class StatusListCellRenderer extends DefaultListCellRenderer {
    private Icon[] icones = {
        new ImageIcon(getClass().getResource("/br/org/espmessenger/cliente/icones/grandes/usuario_conectado.png")),
        new ImageIcon(getClass().getResource("/br/org/espmessenger/cliente/icones/grandes/usuario_desconectado.png")),
        new ImageIcon(getClass().getResource("/br/org/espmessenger/cliente/icones/grandes/usuario_ausente.png")),
        new ImageIcon(getClass().getResource("/br/org/espmessenger/cliente/icones/grandes/usuario_ocupado.png"))
    };

    @Override
    public JLabel getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        if (value != null) {
            Status valor = (Status) value;
            label.setIcon(icones[valor.ordinal()]);
            label.setText(valor.name().toLowerCase());
        }
        
        return label;
    }

}
